﻿@model Telecom.Data.ROLE_MENUS
@{  AjaxOptions ajaxOpts = new AjaxOptions
    {
        HttpMethod = "post",
        OnComplete = "completedAjaxRequestRMID"
    };
}




@using (Ajax.BeginForm("UpdateMenuOnRoles", "PhanQuyen", null, ajaxOpts, new { enctype = "multipart/form-data" }))
{
    <div id="content_load_mast">
        <div class="NoticeBox css_table_form">
            @Html.HiddenFor(model => model.RMID, new {})
            @Html.HiddenFor(model => model.ROLEID, new { id="ROLEID_ADUP_RM"})
            @Html.HiddenFor(model => model.MENUID, new { id="MENUID_ADUP_RM"})
            <input type="hidden" id="MenuUpdateIdOld" value="@Model.MENUID" name="MenuUpdateIdOld" />
            <input type="hidden" id="RolesUpdateIdOld" value="@Model.ROLEID" name="RolesUpdateIdOld" />

            <table class="css_form">
                <tr style="margin-bottom:20px">
                    <td>Role:</td>
                    <td><input class="easyui-combobox" value="@Model.ROLEID" style="width:188px" id="RolesID_MENUOnROLES" name="RolesID_MENUOnROLES" /></td>
                </tr>
                <tr style="margin-bottom:20px">
                    <td>Menu Parent:</td>
                    <td><input class="easyui-combobox" value="@ViewBag.MMID" style="width:188px" id="MenuPrentID_MENUOnROLES" name="MenuPrentID_MENUOnROLES" /></td>
                </tr>
                <tr style="margin-bottom:20px">
                    <td>Menu:</td>
                    <td><input class="easyui-combobox" value="@Model.MENUID" style="width:188px" id="MenuID_MENUOnROLES" name="MenuID_MENUOnROLES" /></td>
                </tr>
             </table>
        </div>
        <br />
        <div class="footer_submit" style="text-align:center; padding-bottom:0px">
            <div class="warning-area"></div>
            <button type="submit" onclick="return makeloading('content_load_mast');">
                <span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">Cập nhật</span><span class="l-btn-icon icon-add">&nbsp;</span></span></button>
            <button type="button" onclick="return close_window_elements('window_Edit_Menu_Roles');">
                <span class="l-btn-left l-btn-icon-left"><span class="l-btn-text">Hủy bỏ</span><span class="l-btn-icon icon-remove">&nbsp;</span></span></button>
        </div>
    </div>
}

<script type="text/javascript">

    $(document).ready(function () {

        $("#RolesID_MENUOnROLES").combobox({
            url: _nameSubDomain + "/PhanQuyen/RolesListStr",
            method: 'get',
            valueField: 'ROLEID',
            textField: 'TEN',
            panelHeight: 'auto',
            onSelect: function (rec) {
                $('#ROLEID_ADUP_RM').val(rec.ROLEID);
            }

        });

        $("#MenuPrentID_MENUOnROLES").combobox({
            url: _nameSubDomain + "/Menu/mainmenuList",
            method: 'get',
            valueField: 'MMID',
            textField: 'TEN',
            panelHeight: 'auto',
            onSelect: function (rec) {
                $("#MenuID_MENUOnROLES").combobox('reload', _nameSubDomain + "/Menu/child_mainmenuList?MMID=" + rec.MMID);
            }

        });

        $("#MenuID_MENUOnROLES").combobox({
            url: _nameSubDomain + "/Menu/child_mainmenuList?MMID=@ViewBag.MMID",
            valueField: 'MENUID',
            textField: 'TEN',
            panelHeight: 'auto',
            onSelect: function (rec) {
                $("#MENUID_ADUP_RM").val(rec.MENUID);
            }
        });

    });

    function completedAjaxRequestRMID(obj) {

        var returnObj = eval('(' + obj.responseText + ')');

        if (returnObj.Status == "success") {

            $('#Roles_TableContainer').datagrid('reload');

            $("#content_load_mast").unmask();

            close_window_elements('window_Edit_Menu_Roles');

        } else {
            $("#content_load_mast").unmask();
            confirmOptionNormal(returnObj.Message);
        }

        return false;
    }

</script>